<div action="" class="layui-form layui-form-pane">

    <div class="layui-form-item">
        <label for="jkstate" class="layui-form-label">监控端状态</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" id="jkstate" lay-verify="required" placeholder="监控端状态"
                   readonly type="text" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="lastheart" class="layui-form-label">最后心跳</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" id="lastheart" lay-verify="required" placeholder="最后心跳时间"
                   readonly type="text">
        </div>
    </div>

    <div class="layui-form-item">
        <label for="lastpay" class="layui-form-label">最后收款</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" id="lastpay" lay-verify="required" placeholder="最后收款时间"
                   readonly type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="input" class="layui-form-label">配置数据</label>
        <div class="layui-input-block">
            <input autocomplete="off" class="layui-input" id="input" lay-verify="required" placeholder="手动配置数据" readonly
                   type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="pzqrcode" class="layui-form-label">配置二维码</label>
        <div class="layui-input-block">
            <img id="pzqrcode" style="max-width: 200px;" alt="" src="">
        </div>
    </div>


    <div class="layui-form-item" style="text-align: right">

        <button class="layui-btn" onclick="window.open('https://gitee.com/yuniks/VMQAPK/releases')">最新版监控端下载</button>

    </div>


</div>

<script>
    function formatDate(now) {
        if (now === 0) {
            return "无";
        }
        now = new Date(now * 1000);
        return now.getFullYear()
            + "-" + (now.getMonth() > 8 ? (now.getMonth() + 1) : "0" + (now.getMonth() + 1))
            + "-" + (now.getDate() > 9 ? now.getDate() : "0" + now.getDate())
            + " " + (now.getHours() > 9 ? now.getHours() : "0" + now.getHours())
            + ":" + (now.getMinutes() > 9 ? now.getMinutes() : "0" + now.getMinutes())
            + ":" + (now.getSeconds() > 9 ? now.getSeconds() : "0" + now.getSeconds());

    }

    layui.use(['layer'], function () {
        var $ = layui.$;

        $.post("<{url('admin/api','JkInfo')}>", function (data) {
            console.log(data);
            data = JSON.parse(data);
            if (data.code === Api_Ok) {
                if (parseInt(data.data.state) === State_Nobind) {
                    $("#jkstate").val("监控端未绑定，请您扫码绑定");
                } else if (parseInt(data.data.state) === State_Offline) {
                    $("#jkstate").val("监控端已掉线，请您检查App是否正常运行");
                } else if (parseInt(data.data.state) === State_Online) {
                    $("#jkstate").val("运行正常");
                }

                $("#lastheart").val(formatDate(data.data.lastheart));
                $("#lastpay").val(formatDate(data.data.lastpay));

                var img = window.location.host + "/" + data.data.key;

                $("#input").val(img);
                $("#pzqrcode").attr("src", "<{url('api/api','Qr')}>?url=" + img);
            }
        });

    });



</script>